import React, {useState} from 'react';

const App = () => {
  
  //状态
  let [num, setNum] = useState(0); 
  const handle = () => {
      setNum((state) => {
        if(state > 3) {
          return state + 3;
        } else {
          return state + 1;
        }
      });
  }
  
  return (
    <div>
      <p>num: {num}</p>
      <button onClick={handle}>累加</button>
    </div>
  )
}

export default App;